import moment from 'moment'

export const formatBoolean = (bool) => {
  if (bool !== null) {
    return bool ? '是' : '否'
  } else {
    return ''
  }
}
export const formatDate = (time) => {
  if (time !== null && time !== '') {
    return moment(time).format('YYYY-MM-DD')
  } else {
    return ''
  }
}

export const formatDateLong = (time) => {
  if (time !== null && time !== '') {
    return moment(time).format('YYYY-MM-DD HH:mm:ss')
  } else {
    return ''
  }
}

// 手机加星号
export const phoneReplace = (value)=>{
  if(value && value!=''){
		var str = value
		if(value.length>=7){
			str = value.substr(0,3)+"****"+value.substr(-4)
		}
		else if(value.length>5 && value.length<7){
			str = value.substr(0,2)+"****"+value.substr(-2)
		}
	  return str;
	} 
}

